<script>
  // Access session storage to make sure it's working.
  sessionStorage.setItem("foo", "bar");
</script>
<script src="common.js"></script>
<h1 id="status">Background</h1>
<div style="display:none" id="pageToScriptTunnel"></div>
<div style="display:none" id="scriptToPageTunnel"></div>

<script>
var counter = 0;

function checkAndIncrementCounter(expected) {
  if (counter != expected) {
    window.close();
    return false;
  }

  counter++;
  return true;
}

window.onload = function() {
  setupScriptTunnel();
  opener.onBackgroundPageLoaded();
}

function onPageBLoaded(pageB) {
  pageB.onBackgroundPageResponded();
}

function onPageBUnloading() {
  notifyBackgroundPageClosing();
  window.close();
}
</script>
